package com.learning.spring.aop.advice.round;

import com.learning.spring.aop.advice.monitor.AopMonitor;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * ClassName: AopRoundAdvice
 * Description: 环绕 Advice
 * 1. 环绕 Advice，允许在目标类方法调用前后织入横切逻辑，综合了前置与后置的功能
 * 2. 实现 AOP 联盟定义的接口 MethodInterceptor，MethodInvocation 对象封装了目标方法、参数、目标方法所在的实例对象等
 * <p>
 * Date: 2019/4/21 15:40 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
public class AopRoundAdvice implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {

        // 前置横切逻辑
        AopMonitor.start();

        // 目标方法调用
        Object proceed = invocation.proceed();

        // 后置横切逻辑
        AopMonitor.end();

        return proceed;
    }
}